home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Admin / ad_stylesets.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  24.0 KB  |  862 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Help Control functions
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 2nd April 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25.  
  26. $idx = new ad_settings();
  27.  
  28.  
  29. class ad_settings {
  30.  
  31.     var $base_url;
  32.  
  33.     function ad_settings() {
  34.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  35.  
  36.         switch($IN['code'])
  37.         {
  38.             case 'wrapper':
  39.                 $this->list_wrappers();
  40.                 break;
  41.                 
  42.             case 'add':
  43.                 $this->do_form('add');
  44.                 break;
  45.                 
  46.             case 'edit':
  47.                 $this->do_form('edit');
  48.                 break;
  49.                 
  50.             case 'doadd':
  51.                 $this->save_skin('add');
  52.                 break;
  53.                 
  54.             case 'doedit':
  55.                 $this->save_skin('edit');
  56.                 break;
  57.                 
  58.             case 'remove':
  59.                 $this->remove();
  60.                 break;
  61.             
  62.             //-------------------------
  63.             case 'memskins':
  64.                 $this->mem_skins();
  65.                 break;
  66.                 
  67.             case 'export':
  68.                 $this->export();
  69.                 break;
  70.                 
  71.             default:
  72.                 $this->list_sets();
  73.                 break;
  74.         }
  75.         
  76.     }
  77.     
  78.     //----------------------------------------------------
  79.     
  80.     function export()
  81.     {
  82.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  83.         
  84.         if ($IN['id'] == "")
  85.         {
  86.             $ADMIN->error("You must specify an existing skin set ID, go back and try again");
  87.         }
  88.         
  89.         //+-------------------------------
  90.         
  91.         $DB->query("SELECT * from ibf_skins WHERE uid='".$IN['id']."'");
  92.         
  93.         if ( ! $row = $DB->fetch_row() )
  94.         {
  95.             $ADMIN->error("Could not query the information from the database");
  96.         }
  97.         
  98.         //+-------------------------------
  99.         
  100.         $DB->query("SELECT * from ibf_images WHERE imid='".$row['img_id']."'");
  101.         
  102.         if ( ! $img = $DB->fetch_row() )
  103.         {
  104.             $ADMIN->error("Could not query the information from the database");
  105.         }
  106.         
  107.         //+-------------------------------
  108.         
  109.         $DB->query("SELECT * from ibf_css WHERE cssid='".$row['css_id']."'");
  110.         
  111.         if ( ! $css = $DB->fetch_row() )
  112.         {
  113.             $ADMIN->error("Could not query the information from the database");
  114.         }
  115.         
  116.         
  117.         //+-------------------------------
  118.         
  119.         $DB->query("SELECT * from ibf_tmpl_names WHERE skid='".$row['set_id']."'");
  120.         
  121.         if ( ! $tmpl = $DB->fetch_row() )
  122.         {
  123.             $ADMIN->error("Could not query the information from the database");
  124.         }
  125.         
  126.         //+-------------------------------
  127.         
  128.         $DB->query("SELECT * from ibf_templates WHERE tmid='".$row['tmpl_id']."'");
  129.         
  130.         if ( ! $wrap = $DB->fetch_row() )
  131.         {
  132.             $ADMIN->error("Could not query the information from the database");
  133.         }
  134.         
  135.         
  136.         //+-------------------------------
  137.         
  138.         if ($INFO['base_dir'] == './')
  139.         {
  140.             $INFO['base_dir'] = str_replace( '\\', '/', getcwd() ) . '/';
  141.         }
  142.         
  143.         $archive_dir   = $INFO['base_dir']."archive_out";
  144.         $images_dir    = $INFO['base_dir']."style_images/".$img['imid'];
  145.         $css_file      = $INFO['base_dir']."style_sheets/stylesheet_{$css['cssid']}.css";
  146.         $templates_dir = $INFO['base_dir']."style_templates/".$tmpl['skid'];
  147.         
  148.         require $root_dir."sources/lib/tar.php";
  149.         
  150.         if (!is_dir($archive_dir))
  151.         {
  152.             $ADMIN->error("Could not locate $archive_dir, is the directory there?");
  153.         }
  154.         
  155.         if (!is_writeable($archive_dir))
  156.         {
  157.             $ADMIN->error("Cannot write in $archive_dir, CHMOD via FTP to 0755 or 0777 to enable this script to write into it. IBF cannot do this for you");
  158.         }
  159.         
  160.         if (!file_exists($css_file))
  161.         {
  162.             $ADMIN->error("Could not locate $css_file, is the directory there?");
  163.         }
  164.         
  165.         if (!is_dir($templates_dir))
  166.         {
  167.             $ADMIN->error("Could not locate $templates_dir, is the directory there?");
  168.         }
  169.         
  170.         if (!is_dir($images_dir))
  171.         {
  172.             $ADMIN->error("Could not locate $images_dir, is the directory there?");
  173.         }
  174.         
  175.         //+-------------------------------
  176.         // Set up the dir structure
  177.         //+-------------------------------
  178.         
  179.         $css_name  = "stylesheet.css";
  180.         $wrap_name = "wrapper.html";
  181.         
  182.         $img_dir   = 'images';
  183.         $templ_dir = 'templates';
  184.         
  185.         $pack_name = preg_replace( "/\s{1,}/", "_", $row['sname'] );
  186.         
  187.         $new_dir = "set-".$pack_name;
  188.         
  189.         //+-------------------------------
  190.         
  191.         if ( ! mkdir($archive_dir."/".$new_dir, 0777) )
  192.         {
  193.             $ADMIN->error("Directory creation failed, cannot export skin set. Please check the permission in 'archive_out'");
  194.         }
  195.         
  196.         //+-------------------------------
  197.         
  198.         if ( ! mkdir($archive_dir."/".$new_dir."/".$img_dir, 0777) )
  199.         {
  200.             $ADMIN->error("Directory creation failed, cannot export skin set. Please check the permission in 'archive_out'");
  201.         }
  202.         
  203.         //+-------------------------------
  204.         
  205.         if ( ! mkdir($archive_dir."/".$new_dir."/".$templ_dir, 0777) )
  206.         {
  207.             $ADMIN->error("Directory creation failed, cannot export skin set. Please check the permission in 'archive_out'");
  208.         }
  209.         
  210.         //+-------------------------------
  211.         // Make the wrapper file...
  212.         //+-------------------------------
  213.         
  214.         $wrap['template'] = preg_replace("/\r/", "\n", $wrap['template'] );
  215.         
  216.         $FH = fopen($archive_dir."/".$new_dir."/".$wrap_name, 'w');
  217.         fwrite($FH, $wrap['template'], strlen($wrap['template']));
  218.         fclose($FH);
  219.         
  220.         @chmod($archive_dir."/".$new_dir."/".$wrap_name, 0777);
  221.         
  222.         //+-------------------------------
  223.         // Make the css file...
  224.         //+-------------------------------
  225.         
  226.         if ( ! copy($css_file, $archive_dir."/".$new_dir."/".$css_name) )
  227.         {
  228.             $ADMIN->error("COPY FAILED ON STYLE SHEET $css_name, maybe the script has insufficient permissions?");
  229.         }
  230.         
  231.         @chmod($archive_dir."/".$new_dir."/".$css_name, 0777);
  232.         
  233.         //+-------------------------------
  234.         // Copy over the images...
  235.         //+-------------------------------
  236.         
  237.         if ( ! $ADMIN->copy_dir($images_dir, $archive_dir."/".$new_dir."/".$img_dir) )
  238.         {
  239.             $ADMIN->error( $ADMIN->errors );
  240.         }
  241.         
  242.         // Generate the config file..
  243.         
  244.         $file_content = "<?php\n\n";
  245.         
  246.         foreach($img as $k => $v)
  247.         {
  248.         
  249.             $v = preg_replace( "#style_images/".$img['imid']."/#", "style_images/%img_dir%/", $v );
  250.         
  251.             $file_content .= "\n\$config['$k'] = \"".addslashes($v)."\";";
  252.         }
  253.         
  254.         $file_content .= "\n\n?".">";
  255.         
  256.         $FH = fopen($archive_dir."/".$new_dir."/"."img_conf.inc", 'w');
  257.         fwrite($FH, $file_content, strlen($file_content));
  258.         fclose($FH);
  259.         
  260.         //+-------------------------------
  261.         // Copy over the skin templates...
  262.         //+-------------------------------
  263.         
  264.         if ( ! $ADMIN->copy_dir($templates_dir, $archive_dir."/".$new_dir."/".$templ_dir) )
  265.         {
  266.             $ADMIN->error( $ADMIN->errors );
  267.         }
  268.         
  269.         // Generate the config file..
  270.         
  271.         $file_content = "<?php\n\n".
  272.                         "\$config=array('author' => \"".addslashes($tmpl['author'])."\", ".
  273.                         "'email'=>\"".addslashes($tmpl['email'])."\", ".
  274.                         "'tbl_border'=>\"".addslashes($row['tbl_border'])."\", ".
  275.                         "'tbl_width'=>\"".addslashes($row['tbl_width'])."\", ".
  276.                         "'url'=>\"".addslashes($tmpl['url'])."\")\n\n?".">";
  277.         
  278.         $FH = fopen($archive_dir."/".$new_dir."/"."templates_conf.inc", 'w');
  279.         fwrite($FH, $file_content, strlen($file_content));
  280.         fclose($FH);
  281.         
  282.         //+-------------------------------
  283.         // Add files and write tarball
  284.         //+-------------------------------
  285.         
  286.         $tar = new tar();
  287.         
  288.         $tar->new_tar( $archive_dir, $new_dir.".tar" );
  289.         $tar->add_directory( $archive_dir."/".$new_dir );
  290.         $tar->write_tar();
  291.         
  292.         // Check for errors.
  293.         
  294.         if ($tar->error != "")
  295.         {
  296.             $ADMIN->error($tar->error);
  297.         }
  298.         
  299.         // remove original unarchived directory
  300.         
  301.         $ADMIN->rm_dir($archive_dir."/".$new_dir);
  302.         
  303.         $ADMIN->done_screen("Skin Pack Export Created<br><br>You can download the tar-chive <a href='archive_out/{$new_dir}.tar' target='_blank'>here</a>", "Manage Skin Sets", "act=sets" );
  304.         
  305.         
  306.     }
  307.     
  308.     //----------------------------------------------
  309.     
  310.     function mem_skins()
  311.     {
  312.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
  313.         
  314.         $DB->query("SELECT sid FROM ibf_skins WHERE uid='".$IN['oid']."'");
  315.         $old = $DB->fetch_row();
  316.         
  317.         if ($IN['nid'] == 'n')
  318.         {
  319.             $DB->query("UPDATE ibf_members SET skin=NULL WHERE skin='".$old['sid']."'");
  320.         }
  321.         else
  322.         {
  323.             $DB->query("SELECT sid FROM ibf_skins WHERE uid='".$IN['nid']."'");
  324.             $new = $DB->fetch_row();
  325.             $DB->query("UPDATE ibf_members SET skin='".$new['sid']."' WHERE skin='".$old['sid']."'");
  326.         }
  327.         
  328.         $ADMIN->done_screen("Member Skin Choices Updated", "Manage Skin Sets", "act=sets" );
  329.         
  330.     }
  331.     
  332.     
  333.     //-------------------------------------------------------------
  334.     // REMOVE WRAPPERS
  335.     //-------------------------------------------------------------
  336.     
  337.     function remove()
  338.     {
  339.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
  340.         
  341.         //+-------------------------------
  342.         
  343.         if ($IN['id'] == "")
  344.         {
  345.             $ADMIN->error("You must specify an existing skin set ID, go back and try again");
  346.         }
  347.         
  348.         //+-------------------------------
  349.         
  350.         $DB->query("SELECT * FROM ibf_skins WHERE uid='".$IN['id']."'");
  351.         
  352.         if (! $skin = $DB->fetch_row() )
  353.         {
  354.             $ADMIN->error("Could not query that skin set information from the DB");
  355.         }
  356.         
  357.         //+-------------------------------
  358.         
  359.         if ($skin['default_set'] == 1)
  360.         {
  361.             $ADMIN->error("You can not remove this skin set as it is set as the default. Set another skin as default and try again");
  362.         }
  363.         
  364.         //+-------------------------------
  365.         
  366.         // Update the members skins..
  367.         
  368.         $DB->query("UPDATE ibf_members SET skin='' WHERE skin='".$skin['sid']."'");
  369.         
  370.         // Update the forums DB
  371.         
  372.         $DB->query("SELECT id FROM ibf_forums WHERE skin_id='".$skin['sid']."'");
  373.         
  374.         if ( $DB->get_num_rows() )
  375.         {
  376.             $arr = array();
  377.             
  378.             while ( $i = $DB->fetch_row() )
  379.             {
  380.                 $arr['forum_skin_'.$i['id']] = '';
  381.             }
  382.         
  383.             $DB->query("UPDATE ibf_forums SET skin_id='' WHERE skin_id='".$skin['sid']."'");
  384.             
  385.             // Remove it from the config file..
  386.             
  387.             $ADMIN->rebuild_config($arr);
  388.             
  389.         }
  390.         
  391.         // Remove skin from the DB
  392.         
  393.         $DB->query("DELETE FROM ibf_skins WHERE uid='".$IN['id']."'");
  394.         
  395.         $std->boink_it($SKIN->base_url."&act=sets");
  396.             
  397.         exit();
  398.         
  399.         
  400.     }
  401.     
  402.     
  403.     
  404.     //-------------------------------------------------------------
  405.     // ADD / EDIT SKIN SETS
  406.     //-------------------------------------------------------------
  407.     
  408.     function save_skin( $type='add' )
  409.     {
  410.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
  411.         
  412.         //+-------------------------------
  413.         
  414.         if ($type == 'edit')
  415.         {
  416.             if ($IN['id'] == "")
  417.             {
  418.                 $ADMIN->error("You must specify an existing skin set ID, go back and try again");
  419.             }
  420.         }
  421.         
  422.         if ($IN['sname'] == "")
  423.         {
  424.             $ADMIN->error("You must specify a name for this skin pack ID");
  425.         }
  426.         
  427.         if ($IN['tbl_width'] == "")
  428.         {
  429.             $ADMIN->error("You must specify a table width");
  430.         }
  431.         
  432.         $barney = array( 'sname'      => stripslashes($HTTP_POST_VARS['sname']),
  433.                          'set_id'     => $IN['template'],
  434.                          'tmpl_id'    => $IN['wrapper'],
  435.                          'img_id'     => $IN['image'],
  436.                          'css_id'     => $IN['css'],
  437.                          'tbl_border' => $IN['tbl_border'],
  438.                          'tbl_width'  => $IN['tbl_width'],
  439.                          'hidden'     => $IN['hidden'],
  440.                          'default_set'=> $IN['default_set'],
  441.                        );
  442.                        
  443.         if ($type == 'add')
  444.         {
  445.         
  446.             $DB->query("SELECT MAX(sid) as new_id FROM ibf_skins");
  447.             
  448.             $row = $DB->fetch_row();
  449.             
  450.             $barney['sid'] = $row['new_id'] + 1;
  451.         
  452.             $db_string = $DB->compile_db_insert_string( $barney );
  453.             
  454.             $DB->query("INSERT INTO ibf_skins (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")");
  455.             
  456.             if ($IN['default_set'] == 1)
  457.             {
  458.                 $DB->query("UPDATE ibf_skins SET default_set=0 WHERE sid <> '".$barney['sid']."'");
  459.             }
  460.             
  461.             $std->boink_it($SKIN->base_url."&act=sets");
  462.             
  463.             exit();
  464.             
  465.         }
  466.         else
  467.         {
  468.             $db_string = $DB->compile_db_update_string( $barney );
  469.             
  470.             $DB->query("UPDATE ibf_skins SET $db_string WHERE uid='".$IN['id']."'");
  471.             
  472.             if ($IN['default_set'] == 1)
  473.             {
  474.                 $DB->query("UPDATE ibf_skins SET default_set=0 WHERE uid <> '".$IN['id']."'");
  475.             }
  476.             
  477.             $ADMIN->done_screen("Skin Set Updated", "Manage Skin Sets", "act=sets" );
  478.         }
  479.         
  480.         
  481.     }
  482.     
  483.     //-------------------------------------------------------------
  484.     // ADD / EDIT SETS
  485.     //-------------------------------------------------------------
  486.     
  487.     function do_form( $type='add' )
  488.     {
  489.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  490.         
  491.         //+-------------------------------
  492.         
  493.         $css       = array();
  494.         $wrappers  = array();
  495.         $templates = array();
  496.         $images    = array();
  497.         
  498.         //+-------------------------------
  499.         
  500.         if ($IN['id'] == "")
  501.         {
  502.             $ADMIN->error("You must specify an existing wrapper ID, go back and try again");
  503.         }
  504.         
  505.         //+-------------------------------
  506.         
  507.         $DB->query("SELECT * from ibf_skins WHERE uid='".$IN['id']."'");
  508.         
  509.         if ( ! $row = $DB->fetch_row() )
  510.         {
  511.             $ADMIN->error("Could not query the information from the database");
  512.         }
  513.         
  514.         //+-------------------------------
  515.         
  516.         $DB->query("SELECT imid, setname FROM ibf_images");
  517.         
  518.         while( $img = $DB->fetch_row() )
  519.         {
  520.             $images[] = array( $img['imid'], $img['setname'] );
  521.         }
  522.         
  523.         //+-------------------------------
  524.         
  525.         $DB->query("SELECT cssid, css_name FROM ibf_css");
  526.         
  527.         while ( $c = $DB->fetch_row() )
  528.         {
  529.             $css[] = array( $c['cssid'], $c['css_name'] );
  530.         }
  531.         
  532.         //+-------------------------------
  533.         
  534.         $DB->query("SELECT tmid, name FROM ibf_templates");
  535.         
  536.         while ( $t = $DB->fetch_row() )
  537.         {
  538.             $wrappers[] = array( $t['tmid'], $t['name'] );
  539.         }
  540.         
  541.         //+-------------------------------
  542.         
  543.         $DB->query("SELECT skid, skname FROM ibf_tmpl_names");
  544.         
  545.         while ( $s = $DB->fetch_row() )
  546.         {
  547.             $templates[] = array( $s['skid'], $s['skname'] );
  548.         }
  549.         
  550.         
  551.         //+-------------------------------
  552.         
  553.         if ($type == 'add')
  554.         {
  555.             $code = 'doadd';
  556.             $button = 'Create Skin Set';
  557.             $row['sname'] = $row['sname'].".2";
  558.             $row['default_set'] = 0;
  559.         }
  560.         else
  561.         {
  562.             $code = 'doedit';
  563.             $button = 'Edit Skin Set';
  564.         }
  565.         
  566.         //+-------------------------------
  567.     
  568.         $ADMIN->page_detail = "You may mix n' match which skin resources you wish to apply to this skin set.";
  569.         $ADMIN->page_title  = "Manage Skin Sets";
  570.         
  571.         //+-------------------------------
  572.         
  573.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , $code      ),
  574.                                                   2 => array( 'act'   , 'sets'      ),
  575.                                                   3 => array( 'id'    , $IN['id']   ),
  576.                                          ), "theAdminForm", "onSubmit=\"return no_specialchars('sets')\""    );
  577.                                          
  578.         //+-------------------------------
  579.         
  580.         $SKIN->td_header[] = array( " "  , "40%" );
  581.         $SKIN->td_header[] = array( " "  , "60%" );
  582.  
  583.         //+-------------------------------
  584.         
  585.         $ADMIN->html .= $SKIN->start_table( $button );
  586.         
  587.         $ADMIN->html .= $SKIN->js_no_specialchars();
  588.         
  589.         $ADMIN->html .= $SKIN->add_td_row( array( 
  590.                                                     "<b>Skin Set Title</b>",
  591.                                                     $SKIN->form_input('sname', $row['sname']),
  592.                                          )      );
  593.                                          
  594.         $ADMIN->html .= $SKIN->add_td_row( array( 
  595.                                                     "<b>Use Templates:</b>",
  596.                                                     $SKIN->form_dropdown('template', $templates, $row['set_id']),
  597.                                          )      );
  598.                                          
  599.         $ADMIN->html .= $SKIN->add_td_row( array( 
  600.                                                     "<b>Use Image & Macro Set:</b>",
  601.                                                     $SKIN->form_dropdown('image', $images, $row['img_id']),
  602.                                          )      );
  603.                                          
  604.         $ADMIN->html .= $SKIN->add_td_row( array( 
  605.                                                     "<b>Use Stylesheet:</b>",
  606.                                                     $SKIN->form_dropdown('css', $css, $row['css_id']),
  607.                                          )      );
  608.                                          
  609.         $ADMIN->html .= $SKIN->add_td_row( array( 
  610.                                                     "<b>Use Wrapper:</b>",
  611.                                                     $SKIN->form_dropdown('wrapper', $wrappers, $row['tmpl_id']),
  612.                                          )      );
  613.                                          
  614.         $ADMIN->html .= $SKIN->add_td_row( array( 
  615.                                                     "<b>Basic Table Width:</b>",
  616.                                                     $SKIN->form_input('tbl_width', $row['tbl_width']),
  617.                                          )      );
  618.                                          
  619.         $ADMIN->html .= $SKIN->add_td_row( array( 
  620.                                                     "<b>Basic Table Border Colour:</b>",
  621.                                                     $SKIN->form_input('tbl_border', $row['tbl_border']),
  622.                                          )      );
  623.                                          
  624.         $ADMIN->html .= $SKIN->add_td_row( array( 
  625.                                                     "<b>Hide from Members?</b><br>Useful if you want to make a forum only skin",
  626.                                                     $SKIN->form_yes_no('hidden', $row['hidden']),
  627.                                          )      );
  628.                                          
  629.         $ADMIN->html .= $SKIN->add_td_row( array( 
  630.                                                     "<b>Set as default skin set?</b><br>Used for unallocted forum and member skins",
  631.                                                     $SKIN->form_yes_no('default_set', $row['default_set']),
  632.                                          )      );
  633.                                                  
  634.         $ADMIN->html .= $SKIN->end_form($button);
  635.                                          
  636.         $ADMIN->html .= $SKIN->end_table();
  637.         
  638.         //+-------------------------------
  639.         //+-------------------------------
  640.         
  641.         $ADMIN->output();
  642.         
  643.         
  644.     }
  645.     
  646.     //-------------------------------------------------------------
  647.     // SHOW WRAPPERS
  648.     //-------------------------------------------------------------
  649.     
  650.     function list_sets()
  651.     {
  652.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  653.         
  654.         $form_array = array();
  655.         
  656.         $forums      = array();
  657.         $forum_skins = array();
  658.     
  659.         $ADMIN->page_detail = "You may add/edit and remove skin sets.<br><br>Skin sets are groups of style resources. You can mix n' match board wrappers, image and macro sets, stylesheets and skin templates. If you wish to edit any of the resources, please choose the resource you wish to manage from the menu bar on the left.";
  660.         $ADMIN->page_title  = "Manage Skin Sets";
  661.         
  662.         //+-------------------------------
  663.         
  664.         $DB->query("SELECT id, name FROM ibf_forums");
  665.         
  666.         while ( $f = $DB->fetch_row() )
  667.         {
  668.             $forums[ $f['id'] ] = $f['name'];
  669.             
  670.             if ($INFO['forum_skin_'.$f['id']] != "")
  671.             {
  672.                 $forum_skins[ $INFO['forum_skin_'.$f['id']] ][] = $f['name'];
  673.             }
  674.         }
  675.         
  676.         
  677.         $SKIN->td_header[] = array( "Title"       , "40%" );
  678.         $SKIN->td_header[] = array( "No. Members" , "20%" );
  679.         $SKIN->td_header[] = array( "Export"      , "10%" );
  680.         $SKIN->td_header[] = array( "Edit"        , "10%" );
  681.         $SKIN->td_header[] = array( "Remove"      , "10%" );
  682.         $SKIN->td_header[] = array( "Hidden"      , "5%" );
  683.         $SKIN->td_header[] = array( "Default"     , "5%" );
  684.         
  685.         //+-------------------------------
  686.         
  687.         $DB->query("select ibf_skins.*, count(ibf_members.id) as mcount from ibf_skins left join ibf_members on(ibf_members.skin=ibf_skins.sid) where (ibf_members.skin is not null or ibf_skins.default_set = 1) group by ibf_skins.sid order by ibf_skins.sname");
  688.         
  689.         $used_ids = array();
  690.         
  691.         if ( $DB->get_num_rows() )
  692.         {
  693.         
  694.             $ADMIN->html .= $SKIN->start_table( "Current Skins Used by Members" );
  695.             
  696.             while ( $r = $DB->fetch_row() )
  697.             {
  698.                 $extra = "";
  699.                 
  700.                 if ( is_array($forum_skins[ $r['sid'] ]) )
  701.                 {
  702.                     if ( count($forum_skins[ $r['sid'] ]) > 0 )
  703.                     {
  704.                         $extra = "<br>(Used in forums: ".implode( ",", $forum_skins[ $r['sid'] ] )." )";
  705.                     }
  706.                 }
  707.                 
  708.                 $default = ' ';
  709.                 $hidden  = ' ';
  710.                 
  711.                 if ($r['hidden'] == 1)
  712.                 {
  713.                     $hidden = "<span style='color:red;font-weight:bold'>X</span>";
  714.                 }
  715.                 
  716.                 if ($r['default_set'] == 1)
  717.                 {
  718.                     $default = "<span style='color:red;font-weight:bold'>X</span>";
  719.                 }
  720.                 
  721.                 $ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['sname'])."</b>$extra",
  722.                                                           "<center>".$r['mcount']."</center>",
  723.                                                           "<center><a href='".$SKIN->base_url."&act=sets&code=export&id={$r['uid']}'>Export</a></center>",
  724.                                                           "<center><a href='".$SKIN->base_url."&act=sets&code=edit&id={$r['uid']}'>Edit</a></center>",
  725.                                                           "<center><a href='".$SKIN->base_url."&act=sets&code=remove&id={$r['uid']}'>Remove</a></center>",
  726.                                                           "<center>$hidden</center>",
  727.                                                           "<center>$default</center>",
  728.                                                  )      );
  729.                                                    
  730.                 $used_ids[] = $r['uid'];
  731.                 
  732.                 $form_array[] = array( $r['uid'], $r['sname'] );
  733.                 
  734.             }
  735.             
  736.             $ADMIN->html .= $SKIN->end_table();
  737.         }
  738.         
  739.         if ( count($used_ids) > 0 )
  740.         {
  741.         
  742.             $DB->query("SELECT * FROM ibf_skins WHERE uid NOT IN(".implode(",",$used_ids).")");
  743.         
  744.             if ( $DB->get_num_rows() )
  745.             {
  746.             
  747.                 $SKIN->td_header[] = array( "Title"  , "60%" );
  748.                 $SKIN->td_header[] = array( "Export" , "10%" );
  749.                 $SKIN->td_header[] = array( "Edit"   , "10%" );
  750.                 $SKIN->td_header[] = array( "Remove" , "10%" );
  751.                 $SKIN->td_header[] = array( "Hidden" , "5%" );
  752.                 $SKIN->td_header[] = array( "Default", "5%" );
  753.             
  754.                 $ADMIN->html .= $SKIN->start_table( "Skin Sets not used by Members" );
  755.                 
  756.                 while ( $r = $DB->fetch_row() )
  757.                 {
  758.                     
  759.                     $extra = "";
  760.                 
  761.                 if ( is_array($forum_skins[ $r['sid'] ]) )
  762.                 {
  763.                     if ( count($forum_skins[ $r['sid'] ]) > 0 )
  764.                     {
  765.                         $extra = "<br>(Used in forums: ".implode( ",", $forum_skins[ $r['sid'] ] )." )";
  766.                     }
  767.                 }
  768.                 
  769.                 $default = ' ';
  770.                 $hidden  = ' ';
  771.                 
  772.                 if ($r['hidden'] == 1)
  773.                 {
  774.                     $hidden = "<span style='color:red;font-weight:bold'>X</span>";
  775.                 }
  776.                 
  777.                 if ($r['default_set'] == 1)
  778.                 {
  779.                     $default = "<span style='color:red;font-weight:bold'>X</span>";
  780.                 }
  781.                 
  782.                 $ADMIN->html .= $SKIN->js_checkdelete();
  783.                 
  784.             
  785.                 $ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['sname'])."</b>$extra",
  786.                                                           "<center><a href='".$SKIN->base_url."&act=sets&code=export&id={$r['uid']}'>Export</a></center>",
  787.                                                           "<center><a href='".$SKIN->base_url."&act=sets&code=edit&id={$r['uid']}'>Edit</a></center>",
  788.                                                           "<center><a href='javascript:checkdelete(\"act=sets&code=remove&id={$r['uid']}\")'>Remove</a></center>",
  789.                                                           "<center>$hidden</center>",
  790.                                                           "<center>$default</center>",
  791.                                                  )      );
  792.                                                      
  793.                     $form_array[] = array( $r['uid'], $r['sname'] );
  794.                                                        
  795.                 }
  796.                 
  797.                 $ADMIN->html .= $SKIN->end_table();
  798.             }
  799.         }
  800.         
  801.         //+-------------------------------
  802.         //+-------------------------------
  803.         
  804.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'add'     ),
  805.                                                   2 => array( 'act'   , 'sets'    ),
  806.                                          )      );
  807.         
  808.         $SKIN->td_header[] = array( " "  , "40%" );
  809.         $SKIN->td_header[] = array( " "  , "60%" );
  810.         
  811.         $ADMIN->html .= $SKIN->start_table( "Create New Skin Set" );
  812.             
  813.         //+-------------------------------
  814.         
  815.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Base new skin set on...</b>" ,
  816.                                                     $SKIN->form_dropdown( "id", $form_array)
  817.                                  )      );
  818.         
  819.         $ADMIN->html .= $SKIN->end_form("Create new Skin Set");
  820.                                          
  821.         $ADMIN->html .= $SKIN->end_table();
  822.         
  823.         //+-------------------------------
  824.         //+-------------------------------
  825.         
  826.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'memskins'     ),
  827.                                                   2 => array( 'act'   , 'sets'         ),
  828.                                          )      );
  829.         
  830.         $SKIN->td_header[] = array( " "  , "40%" );
  831.         $SKIN->td_header[] = array( " "  , "60%" );
  832.         
  833.         $ADMIN->html .= $SKIN->start_table( "Swop members skin choice" );
  834.             
  835.         //+-------------------------------
  836.         
  837.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Where members use skin...</b>",
  838.                                                     $SKIN->form_dropdown( "oid", $form_array)
  839.                                  )      );
  840.                                  
  841.         $form_array[] = array( 'n', 'None (Will use whatever is set as default)' );
  842.                                  
  843.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>update to use skin...</b>",
  844.                                                     $SKIN->form_dropdown( "nid", $form_array)
  845.                                  )      );
  846.         
  847.         $ADMIN->html .= $SKIN->end_form("Update members skin choice");
  848.                                          
  849.         $ADMIN->html .= $SKIN->end_table();
  850.         
  851.         //+-------------------------------
  852.         //+-------------------------------
  853.         
  854.         $ADMIN->output();
  855.     
  856.     }
  857.     
  858.     
  859. }
  860.  
  861.  
  862. ?>